package com.example.smartcity_poverty.ui.AllService.Attorneys.adapter

import android.content.Intent
import com.example.smartcity_poverty.App.Companion.url
import com.example.smartcity_poverty.Base.BaseRecyclerAdapter
import com.example.smartcity_poverty.logic.model.Attreneys.AttListModel
import com.example.smartcity_poverty.logic.util.Util.glide
import com.example.smartcity_poverty.ui.AllService.Attorneys.activity.AttorneysShowActivity
import kotlinx.android.synthetic.main.re_att_home_list_all.*

/**
 *  created by ikun
 *  ANDROID STUDIO - version 4.0
 *  email: jinkunwei41@gmail.com
 * --------------------------------
 *  本月上榜优选律师列表适配器
 **/
class AttListAdapter (
    val list: MutableList<AttListModel.DataBean>,
    layoutId: Int
) : BaseRecyclerAdapter<AttListModel.DataBean>(list, layoutId){
    override fun setData(
        view: BaseViewHolder.ViewFind,
        data: AttListModel.DataBean,
        position: Int,
        holder: BaseViewHolder
    ) {
        // 填充数据
        val d = list[position]
        val fv = holder.viewFind
        val con = holder.viewFind.view?.context

        glide(url + d.avatarUrl, fv.attListUserImage)
        fv.attListUserName.text = d.name
        fv.attListUserTime.text = "工作起始时间: ${d.workStartAt}"
        fv.attListUserSize.text = "咨询人数: ${d.serviceTimes}人"
        fv.attListUserYes.text = "法律专长: ${d.legalExpertiseName}"
        fv.attListUserAll.text = "好评率: ${d.favorableCount}%"

        fv.attListUserBtnOk.setOnClickListener {
            con?.startActivity(Intent(con, AttorneysShowActivity::class.java).apply {
                putExtra("id", d.id.toString())
            })
        }

    }
}